from find_delete_file import FindSuffixFile
from find_delete_file import DeleteFile
from find_delete_file import FindSuffixFile_DF
import logging, log

test_logger = logging.getLogger('Master.Test')

def test_find_delete():
    """
    Find the files and delete them
    """
    # test1 - search txt
    addr = r'C:\Users\cheney\Documents\WeChat Files\wxid_1psnt38scd2f22\FileStorage\File\2021-07'
    suffix = 'txt'
    fs = FindSuffixFile(addr, suffix)
    fs.start_search()
    test_logger.info('Search result:\n{0}'.format(fs.get_search_result()))

    # test2 - search docx
    addr = r'C:\Users\cheney\Documents\WeChat Files\wxid_1psnt38scd2f22\FileStorage\File\2021-05'
    suffix = 'docx'
    fs.set_addr(addr)
    fs.set_suffix(suffix)
    fs.start_search()
    test_logger.info('Search result:\n{0}'.format(fs.get_search_result()))

    # test3 - search txt1 and delete them
    addr = r'C:\Users\cheney\Documents\WeChat Files\wxid_1psnt38scd2f22\FileStorage\File\2021-07'
    suffix = 'txt1'
    fs.set_addr(addr)
    fs.set_suffix(suffix)
    fs.start_search()
    test_logger.info('Search result:\n{0}'.format(fs.get_search_result()))

    df = DeleteFile(fs.get_search_result())
    df.start_delete()

def test_find_delete_inherit():
    """
    Find the files and delete them , using another way - inherit
    :return: None
    """
    addr = r'C:\Users\cheney\Desktop'
    suffix = 'png'
    fs = FindSuffixFile_DF(addr, suffix)
    fs.start_search()
    test_logger.info('Search result:\n{0}'.format(fs.get_search_result()))
    fs.start_delete()

def delete_png_data_analysis():
    """
    In my working, I need to delete png files every step
    :return: None
    """
    addr = r'C:\Users\cheney\Desktop'
    suffix = 'png'
    fs = FindSuffixFile(addr, suffix)
    fs.start_search()
    test_logger.info('Search result:\n{0}'.format(fs.get_search_result()))

    df = DeleteFile(fs.get_search_result())
    df.start_delete()

if __name__ == '__main__':
    #test
    #test.delete_png_data_analysis()
    test_find_delete_inherit()